#!/usr/bin/env python2
from __future__ import print_function

from benchmarker import *
import time

@className('benchmark.WalkthoughArray')
#@className('benchmark.RandomwalkArray')
@appParams({'arraysize':1000, 'wcycles':10000, 'wtimes':5, 'bcycles':10000})
class memoryAccess(benchmarker):
	def run(self):
		super(memoryAccess, self).run()

def benchmarkCycles():
	b = memoryAccess()
	output('array size,cycles,result')
	for cycle in range(1000, 100001, 500):
		b.appParams['bcycles'] = cycle
		b.run()
		result = str(b.appParams['arraysize']) + ',' + str(cycle) + ',' + str(b.getResult())
		output(result)
		time.sleep(1)

def benchmarkSize():
	b = memoryAccess()
	f = open('out.csv', 'w+')
	print('cycles,array size,result', file=f)
	f.flush()
	b.appParams['bcycles'] = 50000

	kb = 128
	mb = 1024 * kb

	for size in range(8 * kb, 512 * kb + 1, 8 * kb):
		b.appParams['arraysize'] = size
		b.run()
		result = str(b.appParams['bcycles']) + ',' + str(size) + ',' + str(b.getResult())
		f.flush()
		print(result, file=f)
		time.sleep(1)

def main():
	benchmarkSize()


if __name__ == '__main__':
	main()

